<template>
  <div class="myTimeselect">
    <el-time-select
      :editable="editable"
      :clearable="clearable"
      v-model.lazy="childModel"
      :value-format="valueFormat"
      :picker-options="pickerOptions"
      @change="change(childModel)"
      placeholder="请选择时间"
      class="el-form-item-all_input"
    >
    </el-time-select>
  </div>
</template>

<script>

export default {
  name: 'myTimeselect',
  props: {
    // 当前组件绑定值
    model: {
      type: String,
      require: true
    },
    // 文本框可输入
    editable: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 是否显示清除按钮
    clearable: {
      type: Boolean,
      default () {
        return false
      }
    },
    // 可选，绑定值的格式。不指定则绑定值为 Date 对象
    valueFormat: {
      type: String,
      default () {
        return 'HH:mm'
      }
    },
    // 当前时间日期选择器特有的选项参考下表
    pickerOptions: {
      type: Object,
      default () {
        return {start: '00:00', step: '00:01', end: '23:59'}
      }
    },
    // 当前组件change改变方法
    change: {
      type: Function,
      default (val) {

      }
    }
  },
  data () {
    return {
      childModel: this.model
    }
  },
  watch: {
    childModel: function (val) {
      this.$emit('update:model', val)
    },
    model (val) {
      if (val !== this.childModel) {
        this.childModel = val
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss">
</style>
